<style>
	html,body{
		margin: 0;
		padding:0;
	}
</style>
<style scoped>
	.form{
		width: 96%;
    margin-left: 2%;
	}
	.campName{
		width: 100%;
    height: 2em;
    font-size: 1.5em;
    border: 0;
    margin: 1em auto;
	}
	.sizeone::-webkit-input-placeholder{
		font-size: 1em;
		color:#D9D9D9;
	}
	.sizeone::-moz-placeholder{
		font-size: 1em;
		color:#D9D9D9;
	}
	.sizeone:-moz-placeholder{
		font-size: 1em;
		color:#D9D9D9;
	}
	.sizeone::-ms-input-placeholder{
		font-size: 1em;
		color:#D9D9D9;
	}

	.sizetwo>input::-webkit-input-placeholder{
		font-size: 12px;
		color:#D9D9D9;
	}
	.sizetwo>input::-moz-placeholder{
		font-size: 12px;
		color:#D9D9D9;
	}
	.sizetwo>input:-moz-placeholder{
		font-size: 12px;
		color:#D9D9D9;
	}
	.sizetwo>input::-ms-input-placeholder{
		font-size: 12px;
		color:#D9D9D9;
	}

	.count{
		display: inline-block;
		width: 40%;
		margin-top: 15px;
	}
	.count>img {
    vertical-align: top;
	}
	.count>input{
    width: 70%;
    margin-left: 5%;
    height: 24px;
    display: inline-block;
    vertical-align: top;
    border:0;
	}

	.season{
		display: inline-block;
		width: 60%;
	}
	.season>input{
    text-indent: .1em;
    width: 70%;
    margin-left: 5%;
    border:0;
	}

	.summary{
		width: 100%;
    height: 2em;
    font-size: 1.5em;
    border: 0;
	}

	.tips{
		width: 100%;
    height: 2em;
    font-size: 1.5em;
    border: 0;
	}

	.line{
		width: 100%;
    height: 2em;
    font-size: 1.5em;
    border: 0;
	}

	.address>input{
    text-indent: .1em;
    margin-top: .3em;
    border:0;
	}

	.charge>input{
    text-indent: .1em;
    margin-top: .3em;
    border:0;
	}

	button.sendcamp {
		position: relative;
    background: #FD8C25;
    width: 100%;
    border: 0px solid red;
    height: 48px;
    color: #fff;
    font-size: 24px;
	}	
	.mymap {
		width: 100%;
		height: 60%;
    margin-top: 1em;
	}
	#addrRendezvous{
		display: block;
	}
	.camp{
		color:#D9D9D9;
	}
</style>
<template>
	<div class="form">
		<input v-model="name" type="text" class="campName sizeone" placeholder="输入活动名称...">
		<!-- <uploadpic></uploadpic> -->
		<hr>
		<div class="address sizetwo">
			<input id="addrRendezvous" v-model="address.rendezvous" type="text" placeholder="集合地点">
			<input v-model="address.start" type="text" placeholder="目的地点">
			<input v-model="address.end" type="text" placeholder="出发地点">
		</div>
		<hr>
		<select class="form-control input-sm camp" v-model="placeId">
			<option>请选择一个露营地</option>
			<template v-for="place in places">
				<option :value="place._id">{{place.name}}</option>
			</template>
		</select>
		<hr>
		<div class="count sizetwo">
			<input v-model="maxcount" type="text" placeholder="人员最大数">
		</div>
		<hr>
		<div class="charge sizetwo">
			<input v-model="charge.chargeType" type="text" placeholder="费用类型">
			<input v-model="charge.activityFee" type="text" placeholder="活动费用">
			<input v-model="charge.enrollFee" type="text" placeholder="报名费用">
		</div>
		<hr>
		<div class="contact sizetwo">
			<input v-model="contact.name" type="text" name="contact" placeholder="联系人">
			<input v-model="contact.phone" type="text" name="phone" placeholder="电话">
		</div>
		<hr>
		<div class="time sizetwo">
			<input v-model="time.signupTime" type="text" name="signupTime" placeholder="报名截止时间">
			<input v-model="time.rendezvousTime" type="text" name="rendezvousTime" placeholder="集合时间">
			<input v-model="time.createTime" type="text" name="createTime" placeholder="活动发布日期">
			<input v-model="time.activitystart" type="text" name="activitystart" placeholder="行程开始时间">
			<input v-model="time.activityend" type="text" name="activityend" placeholder="行程结束时间">
		</div>
		<hr>
		<div class="plan sizetwo">
			<input v-model="plan" type="text" name="plan" placeholder="行程安排">
		</div>
		<hr>
		<div class="equipment sizetwo">
			<input v-model="equipment" type="text" name="equipment" placeholder="个人装备">
		</div>
		<hr>
		<div class="tips sizetwo">
			<input v-model="tips" type="text" name="tips" placeholder="注意事项">
		</div>
		<hr>
		<input v-model="attention" type="text" class="tips sizeone" placeholder="重要提醒...">
		<hr>
		
	</div>
	<div class="mymap">
		<mymap></mymap>
	</div>
	<button class="sendcamp" @click="sendcamp">发布</button>
</template>
<script>
	var wxinfo = JSON.parse(window.localStorage.getItem("user"));
	// var wxinfo = {
 //    "openid" : "ospoZwrbG-NsWdMdWu7su143MNSY",
 //    "nickname" : "Kevin💓",
 //    "language" : "zh_CN",
 //    "city" : "Guangzhou",
 //    "province" : "Guangdong",
 //    "country" : "China",
 //    "headimgurl" : "http://wx.qlogo.cn/mmopen/WvFVl7XN9iaTb4A8kico3yqnFHeYVibbCdqJpDRDfjn7DKx0UOeaSVib5Eicuia3VmLQcmws9GTp7UoFAM1aibfpfgGLibmuwibTgtZP6/0",
 //    "subscribe" : 1,
 //    "sex" : true,
	// };

	var uploadpic = require("../component/public/uploadpic.vue");
	var mapinsert = require("../component/public/mapinsert.vue");
	var mymap = require("../component/map.vue");
	module.exports = {
		data:function(){
			return {
				places:[{
					_id:"",
					name:""
				}],
				placeId:"",
				url:"/camp/activity/setInfo",
				name:"",
				tips:"",
				address:{
					start:"",
					rendezvous:"",
					end:"",
				},
				attention:"",
				addrStart:"",
				addrRendezvous:"",
				addrEnd:"",
				charge:{
					chargeType:"",
					activityFee:"",
					enrollFee:""
				},
				contact:{
					name:"",
					phone:""
				},
				time:{
	        signupTime: "",
	        rendezvousTime: "",
	        createTime: "",
	        activitystart: "",
	        activityend: ""
				},
				plan:"",
				equipment:"",
				maxcount:""
			}
		},
		ready:function(){
			this.places = JSON.parse(localStorage.getItem("places"));
		},
		methods:{
			sendcamp:function(){
				var info = {};
				var vue = this;
				info.address = {};
				info.charge = {};
				info.contact = {};
				info.time = {};
				info.name = vue.name;
				info.address.start = vue.address.start;
				info.address.rendezvous = vue.address.rendezvous;
				info.address.end = vue.address.end;
				info.placeId = vue.placeId;
				info.charge.chargeType = vue.charge.chargeType;
				info.charge.activityFee = vue.charge.activityFee*1;
				info.charge.enrollFee = vue.charge.enrollFee*1;
				info.contact.name = vue.contact.name;
				info.contact.phone = vue.contact.phone;
				info.time.signupTime = vue.time.signupTime;
				info.time.rendezvousTime = vue.time.rendezvousTime;
				info.time.createTime = vue.time.createTime;
				info.time.activitystart = vue.time.activitystart;
				info.time.activityend = vue.time.activityend;
				info.plan = vue.plan;
				info.maxcount = vue.maxcount;
				info.equipment = vue.equipment;
				info.tips = vue.tips;
				info.ownerId = wxinfo.openid;
				console.log(info);
				vue.$http.post(vue.url,info).then(function(res){
					alert('活动发布成功')
				},function(err){
					alert('活动发布失败')
					console.log(err);
				});
			}
		},
		components:{
			uploadpic:uploadpic,
			mymap:mymap
		}
	}
</script>